import java.util.StringTokenizer;

public class StringReversal {

	String reverse = "";

	public String reverseString(String str) {
		if (str.length() == 1) {
			return str;
		} else {
			reverse += str.charAt(str.length() - 1)
					+ reverseString(str.substring(0, str.length() - 1));
			return reverse;
		}
	}

	public String reverse(String str) {
		StringTokenizer st = new StringTokenizer(str, " ");
		StringBuffer sb = new StringBuffer();
		String token;
		while (st.hasMoreTokens()) {
			token = st.nextToken();
			String result = reverseString(token);
			this.reverse = "";
			sb.append(result).append(" ");
		}
		return sb.toString();
	}

	public static void main(String a[]) {
		StringReversal srr = new StringReversal();
		System.out.println("Result: " + srr.reverse("Java2 novice"));
	}
}